import pymysql
try:
    conn=pymysql.connect(
        host='localhost',
        port=3306,
        db='devdb',
        user='root',
        passwd='root',
        charset='utf8')
    cur=conn.cursor()

    newID = int(input("请输入新的设备id：\n"))
    newName = input("请输入设备名字：\n")
    newUser = input("请输入设备使用者：\n")
    newPlace = input("请输入设备放置位置：\n")
    sql = "insert into devmanage values(%d,%s,%s,%s)"
    params = (newID, newName, newUser, newPlace)
    cur.execute(sql, params)
    conn.commit()
    cur.close()
    conn.close()
except Exception:
    print("数据库连接错误")